<template>
	<!-- #ifndef MP-WEIXIN -->
	<view class="data">
	  <el-form label-width="80px" class="form-item">
	    <el-form-item label="用户昵称">
	      <el-input v-model="form.username"></el-input>
	    </el-form-item>
		  <el-form-item label="手机账号">
		    <el-input v-model="form.phone"></el-input>
		  </el-form-item>
	    <el-form-item label="密碼">
	      <el-input type="password" v-model="form.password"></el-input>
	    </el-form-item>
	    <el-form-item label="头像">
	      <el-input v-model="form.avatar"></el-input>
	    </el-form-item>
	    <el-form-item label="个性签名">
	      <el-input v-model="form.per_signature"></el-input>
	    </el-form-item>
	    <el-form-item>
	      <el-radio v-model="form.sex" label="男">男</el-radio>
	      <el-radio v-model="form.sex" label="女">女</el-radio>
	    </el-form-item>
	    <el-form-item>
	      <el-button type="primary" @click="onSubmit">提交</el-button>
	    </el-form-item>
	  </el-form>
	</view>
	<!-- #endif -->
  
</template>

<script>
export default {
	props:["userList"],
  data() {
    return {
      form: {
        username: "",
        password: "",
        avatar: "",
        per_signature: "",
        phone: "",
        sex: ""
      }
    };
  },
  mounted() {
  	this.form = this.userList
  },
  methods: {
    onSubmit() {
		uni.request({
			url: 'http://localhost:8081/user/updateInfo',
			method: 'PUT',
			data: this.form,
			header: {
				'Content-Type': 'application/json'
			},
			dataType: 'json',
			success: (res) => {
				if (res.data.state == 200) {
					uni.$u.toast(res.data.message)
				} else {
					uni.$u.toast(res.data.message)
				}
			}
		})
      //封装成json格式
      
      // var objdata = JSON.stringify(this.form);
      // this.$http.post('admin/edituser', objdata).then(result => {
      //   // console.log(result.body);
      //   if(result.body.flag==true){
      //     //弹出登录成功
      //     this.$message.success(result.body.message);
      //   } else {
      //     // 弹出通知框提示登录失败信息
      //     this.$message.error("修改失败！");
      //   }
      // });
    }
  }
};
</script>

<style>
.data {
  width: 100%;
  height: 100%;
}
.form-item {
  width: 30%;
  margin: auto;
}
</style>